package com.yitiao.data_algorithms.leetcode.editor.cn;

import java.util.ArrayList;
import java.util.List;

class GenerateParentheses{
    // 2022-09-01 12:50:57
    public static void main(String[] args) {
        Solution solution = new GenerateParentheses().new Solution();
    }
    
    //leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public List<String> generateParenthesis(int n) {
        List<String> ans = new ArrayList<>();
        if (n==0)return ans;
        ans.add("()");
        for (int i = 2; i <=n ; i++) {
            for (int j = 0; j < i; j++) {
                ans.add("("+ans.get(j)+")"+ans.get(i-j));
                ans.add("("+ans.get(i-j)+")"+ans.get(j));
            }
        }
        return ans;
    }
}
//leetcode submit region end(Prohibit modification and deletion)

}